package com.qiji.video.web.fcontroller;
import com.github.pagehelper.PageInfo;
import com.qiji.video.bean.VideoPartition;
import com.qiji.video.bean.Videos;
import com.qiji.video.bean.vo.VideosAllVo;
import com.qiji.video.exception.ServiceException;
import com.qiji.video.service.IVideoDisplayService;
import com.qiji.video.service.IVideoService;
import com.qiji.video.util.Result;
import com.qiji.video.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/auth/front/videoDisplay")
@Api( tags = "前台----视频展示")
public class VideoDisplayController {
    @Autowired
    public IVideoService videoService;

    @Autowired
    public IVideoDisplayService iVideoDisplayService;
    @GetMapping("/hotsearch")
    @ApiOperation("热门搜索")
    public Result hotsearch() throws ServiceException {
//       return ResultUtil.success(videoService.hotsearch());
        return ResultUtil.success(iVideoDisplayService.hotSearch());
    }
    @GetMapping("/allSearch")
    @ApiOperation("全网搜")
    public Result allSearch(Integer pageNum,Integer pageSize,String name) throws ServiceException{

//        PageInfo<Videos>  pageInfo = videoService.pageInfoByName(pageNum,pageSize,name);

        PageInfo<VideosAllVo> pageInfo = iVideoDisplayService.pageInfoByName(pageNum,pageSize,name);
        return ResultUtil.success(pageInfo);

    }
    @GetMapping("/carousel")
    @ApiOperation("轮播图接口，如果id=0，则为所有视频的轮播图，否则传入id获得轮播图")
    public Result carouselSelect(Integer id) throws ServiceException{
//        return ResultUtil.success(videoService.selectPartitioningById(id));
        return ResultUtil.success(iVideoDisplayService.carouselSelect(id));
    }
    @GetMapping("/selectPartition")
    @ApiOperation("查询分区")
    public Result selectPartition() throws ServiceException{
        return ResultUtil.success(iVideoDisplayService.selectPartition());
    }
    @GetMapping("/selectPartitionType")
    @ApiOperation("查询分区类型")
    public  Result selectPartitionType(Integer id) throws ServiceException{
        return ResultUtil.success(iVideoDisplayService.selectPartitionType(id));
    }
    @GetMapping("/selectPartitionVideos")
    @ApiOperation("分区视频展示")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "查询视频的ID值",dataType = "int"),
            @ApiImplicitParam(name = "state",value = "根据查询分区类型返回状态值",dataType = "int"),
    })
    public  Result selectPartitionVideos(Integer id, Integer state){
        return ResultUtil.success( iVideoDisplayService.selectPartitionVideos(id,state));
    }

    /**
     *
     */
    @GetMapping("/mayLikes")
    @ApiOperation("猜你喜欢接口，如果id=0，则为所有视频的轮播图，否则传入id获得轮播图")
    public Result mayLikes(Integer id) throws ServiceException{
//        return ResultUtil.success(videoService.selectPartitioningById(id));
//        return ResultUtil.success(iVideoDisplayService.carouselSelect(id));
        return ResultUtil.success(iVideoDisplayService.mayLike(id));
    }

}
